package com.szp.spCloud.common.service.impl;

import com.szp.spCloud.common.service.MailService;
import com.szp.spCloud.mail.util.SimpleMailSender;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Service
public class MailserviceImpl implements MailService {
    Logger logger = LoggerFactory.getLogger(MailserviceImpl.class);
    @Override
    public Boolean sendMail(String email, String code) {
        try{
            SimpleMailSender.sendMessage("smtp.163.com", "szphust@163.com",
                    "SRRHEPDQOIGXJVEA", email, "auth_code",
                    code,
                    "text/html;charset=gb2312");
            return true;
        }catch (Exception e){
            logger.error("发送邮件到{}失败{}", email,e);
            return false;
        }
    }
}
